import re
str = """
#include <sdk/sdk.h>
#include <sdk/stats.h>
#include <iostream>
#include <cstdio>
using namespace std;
string fromPercent(double x){
    char *st = new char[100];
    sprintf(st, "%d\\\\%%", int(x * 100));
    return st;
}
int main(){
freopen("../doc/doc.md", "w", stdout);
cout << R"V0G0N(
"""

fin = open("doc_raw.md", "r", encoding="utf-8")
data = fin.read()

data = re.sub(r"%%(.+?)%%", r')V0G0N";\n\1 cout << R"V0G0N(', data);
data = re.sub(r"{{(.+?)\|\|(.+?)}}", r')V0G0N";\ncout << "$" << from\1(\2) << "$" << "(`\2`)" << R"V0G0N(', data)
data = re.sub(r"{{#(.+?)}}", r')V0G0N";\ncout << "$" << \1 << "$" << R"V0G0N(', data)
data = re.sub(r"{{(.+?)}}", r')V0G0N";\ncout << "$" << \1 << "$" << "(`\1`)" << R"V0G0N(', data)
str += data
str += """
)V0G0N" << endl;
}
"""
fout = open("doc_gen.cpp", "w", encoding="utf-8")
fout.write(str)
